$(function() {
	load_relative = function(page){
		$.get("/load-joke-relative", {
			page:page
		}).done(function( data ) {
			if(data != null){
				var html = "";
				if(page > 1){
					html += "<a class='prevButton' onclick='load_relative(" + (page - 1)+ ")'><img src='/resources/images/prev_icon.png'>Trước</a>";
				}
				if(data.length >= 5) {
					html += "<a class='nextButton' onclick='load_relative(" + (page + 1)+ ")'>Sau<img src='/resources/images/next_icon.png'></a>";
				}
				$('#arrowButtons').html(html);
				
				html = "";
				for (var i = 0; i < data.length; ++i) {
					var obj = data[i];
					html += "<div class='owl-item'><div class='item_tlq'> "
						 +   "<a href='/truyen-cuoi/" + obj.id + "' class='thumb_tlq'> <img src='/resources/data/joke-thumbnails/" + obj.image+ "'></a>"
						 +   "<p class='title_tlq'><a> " + obj.title + " </a></p></div></div>";
				}
				$('#list-other').html(html);
			}
			
		 });
	};
});
